import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;

public class LinkedList1 {
    public static void main(String[] args) {
//        List<Integer> arrayList = new ArrayList<>();
//        arrayList.add(1);
//        arrayList.add(2);
//        List<Integer> linkedList = new LinkedList<>(arrayList);


        List<Integer> linkedList = new LinkedList<>();
        linkedList.add(1);
        linkedList.add(2);
        List<Integer> arrayList = new ArrayList<>(linkedList);
        System.out.println();

        System.out.println(linkedList);

        for(Integer x : linkedList) {
                System.out.print(x + " ");
        }
        System.out.println();

        ListIterator<Integer> lit = linkedList.listIterator();
        while(lit.hasNext()) {
            System.out.print(lit.next() + " ");
        }
        System.out.println();

        ListIterator<Integer> lit2 = linkedList.listIterator(linkedList.size());
        while(lit2.hasPrevious()) {
            System.out.print(lit2.previous() + " ");
        }
        System.out.println();
    }



}
